﻿using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using Rhino.Mocks;
using TSVNAddin.TSVN;
using TSVNAddin.SVN;
using EnvDTE80;
using EnvDTE;
using TSVNAddin.Config;

namespace TSVNAddin.Core.Test
{
	[TestFixture]
	public class GenericPathCommandFixture
	{
		[Test]
		public void Execute()
		{
			string reposiotryPath = @"c:\svn\myproject";
			TortoiseProcCommandType tortoiseCommandType = TortoiseProcCommandType.Update;
			TortoiseProcArgumentType argumentType = TortoiseProcArgumentType.rev;

			var tortoiseProcExecutor = MockRepository.GenerateMock<TortoiseProcExecutor>((ProcessStarter)null, (ConfigStorage)null);
			tortoiseProcExecutor.Expect(x => x.Exec(tortoiseCommandType, reposiotryPath, argumentType));

			var applicationObject = MockRepository.GenerateMock<DTE2>();

			var repositoryPathFinder = MockRepository.GenerateMock<RepositoryPathFinder>((SVNClientAdapter)null);
			repositoryPathFinder.Expect(x => x.FindRootPath(applicationObject)).Return(reposiotryPath);

			GenericPathCommand command = new GenericPathCommand(tortoiseProcExecutor, repositoryPathFinder, tortoiseCommandType, argumentType);
			command.Execute(applicationObject);

			tortoiseProcExecutor.VerifyAllExpectations();
			repositoryPathFinder.VerifyAllExpectations();
		}
	}
}
